<?php

namespace App\Http\Controllers\Api;

use App\Models\Operator;
use Illuminate\Http\Request;

class OperatorController extends BaseController
{
    //
    public function login(Request $request) {
        try{
            $mobile = $request->input('mobile', '');
            if (empty($mobile)) return $this->response(400, '请填写手机号码');
            $password = $request->input('password', '');
            if (empty($password)) return $this->response(400, '请填写登录密码');
            $operator = Operator::where('mobile', $mobile)->where('password', $password)->first();
            if (empty($operator)) return $this->response(400, '手机号码或密码错误');
            return $this->response(200, '登录成功');
        }catch (\Throwable $e) {
            return $this->response(500, $e->getMessage());
        }
    }
}
